package cn.yunlang.zhangZhongFei.controller;

import cn.yunlang.zhangZhongFei.service.BannerService;
import cn.yunlang.zhangZhongFei.vo.response.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import cn.yunlang.zhangZhongFei.entity.Banner;
import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/Banner")
@Api(tags = "首页轮播图")
public class BannerController {

    @Resource
    private BannerService bannerService;

    @ApiOperation("全查，根据图片顺序排序")
    @GetMapping("/list")
    public R<List<Banner>> list() {
        return bannerService.listAll();
    }

    @PostMapping("/add")
    @ApiOperation("新增")
    public R<String> add(@RequestBody Banner banner) {
        return bannerService.addBanner(banner);
    }

    @GetMapping("/delete")
    @ApiOperation("删除")
    public R<String> delete(@RequestParam Long bannerId) {
        return bannerService.deleteBanner(bannerId);
    }

    @PostMapping("/update")
    @ApiOperation("修改")
    public R<String> update(@RequestBody Banner banner) {
        return bannerService.updateBanner(banner);
    }
}